package com.googlecode.garbagecan.simonstudy.myspring;

import org.springframework.aop.Pointcut;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher;

import java.lang.reflect.Method;

public final class MonitoredMeasuringPointcut implements Pointcut {

	private static MonitoredMethodMatcher matcher = new MonitoredMethodMatcher();
	
	public ClassFilter getClassFilter() {
		return ClassFilter.TRUE;
	}

	public MethodMatcher getMethodMatcher() {
		return matcher;
	}

	static class MonitoredMethodMatcher implements MethodMatcher {
		public boolean matches(Method method, Class targetClass) {
			if(targetClass.getName().startsWith("com.googlecode.garbagecan.simonstudy.myspring")) {
				return true;
			} else {
				return false;
			}
		}

		public boolean isRuntime() {
			return false;
		}

		public boolean matches(Method method, Class targetClass, Object[] args) {
			throw new UnsupportedOperationException("This is not a runtime method matcher");
		}
	}
}
